class Spreadsheet:

    def __init__(self, rows: int):
        self.grid = [[0] * 26 for _ in range(rows)]

    def setCell(self, cell: str, value: int) -> None:
        c, r = self.f(cell)
        self.grid[r][c] = value

    def resetCell(self, cell: str) -> None:
        c, r = self.f(cell)
        self.grid[r][c] = 0

    def getValue(self, formula: str) -> int:
        a, b = self.g(formula)
        return self.h(a) + self.h(b)

    def h(self, value):
        if value[0] >= "A" and value[0] <= "Z":
            c, r = self.f(value)
            return self.grid[r][c]
        else:
            return int(value)

    def g(self, formula: str):
        return [formula[1 : (k := formula.index("+")) :], formula[k + 1 : :]]

    def f(self, cell: str):
        return [ord(cell[0]) - ord("A"), int(cell[1::]) - 1]
